import pymysql

# 1、创建数据库链接
with pymysql.connect(host="master", port=3306, database="bigdata31", user="root", password="123456") as con:
    # 2、获取游标,用于执行sql
    cursor = con.cursor()
    # 3、执行sql
    cursor.execute("select id,name,age,gender,clazz from students where gender=%s", "男")
    # 4、读取数据
    students = cursor.fetchall()
    # 5、循环解析数据
    for id, name, age, gender, clazz in students:
        print(id, name, age, gender, clazz)



